package com.cc.config;

import com.alibaba.druid.pool.DruidDataSource;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;

import javax.sql.DataSource;

/**
 * @author 33314
 * @version 1.0
 * @description: TODO
 * @date 2025/9/2 10:41
 */
public class JdbcConfig {
@Value("${driver}")
    public String driver;
@Value("${url}")
public String url;
@Value("${user}")
public String username;
@Value("${password}")
public String password;
@Bean
    public DataSource dataSource(){
//    创建数据源对象
    DruidDataSource dataSource = new DruidDataSource();
    dataSource.setDriverClassName(driver);
    dataSource.setUrl(url);
    dataSource.setUsername(username);
    dataSource.setPassword(password);
    return dataSource;
}
}
